﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
					xmlns:env="xaml://kokomo/environment"
					xmlns:h="clr-namespace:Kokomo.Environment.Hosting"
					xmlns:kui="xaml://kokomo/ui"
					xmlns:doc="clr-namespace:Kokomo.Environment.Documents"
					xmlns:svc="clr-namespace:Kokomo.Environment.Services"
		xmlns:i="clr-namespace:System.Windows.Media.Imaging;assembly=PresentationCore"
					>
	<DataTemplate x:Key="{x:Static env:EditorStyleKeys.CommandViewTemplateKey}">
		<!-- DataType="{x:Type env:CommandViewModel}" -->
		<Grid>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto" SharedSizeGroup="CommandIcon"/>
				<ColumnDefinition Width="Auto"/>
			</Grid.ColumnDefinitions>

			<Image Source="{Binding IconSource}"/>
			<TextBlock Grid.Column="1">
					<Hyperlink Command="{Binding Command}" CommandParameter="{Binding Argument}">
						<TextBlock Text="{Binding Text}"/>
					</Hyperlink>
				</TextBlock>
		</Grid>
	</DataTemplate>

	<PathGeometry x:Key="TreeArrow">
		<PathGeometry.Figures>
			<PathFigureCollection>
				<PathFigure IsFilled="True"
                            StartPoint="0 0"
                            IsClosed="True">
					<PathFigure.Segments>
						<PathSegmentCollection>
							<LineSegment Point="0 6"/>
							<LineSegment Point="6 0"/>
						</PathSegmentCollection>
					</PathFigure.Segments>
				</PathFigure>
			</PathFigureCollection>
		</PathGeometry.Figures>
	</PathGeometry>
	<Style x:Key="{x:Static env:EditorStyleKeys.ExpandCollapseArrowStyleKey}"
		TargetType="ToggleButton">
		<Setter Property="Focusable"
                Value="False"/>
		<Setter Property="Width"
                Value="16"/>
		<Setter Property="Height"
                Value="16"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type ToggleButton}">
					<Border Width="16"
                            Height="16"
                            Background="Transparent"
                            Padding="5,5,5,5">
						<Path x:Name="ExpandPath"
                              Fill="Transparent"
                              Stroke="#FF989898"
                              Data="{StaticResource TreeArrow}">
							<Path.RenderTransform>
								<RotateTransform Angle="135"
                                                 CenterX="3"
                                                 CenterY="3"/>
							</Path.RenderTransform>
						</Path>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver"
                                 Value="True">
							<Setter TargetName="ExpandPath"
                                    Property="Stroke"
                                    Value="#FF1BBBFA"/>
							<Setter TargetName="ExpandPath"
                                    Property="Fill"
                                    Value="Transparent"/>
						</Trigger>

						<Trigger Property="IsChecked"
                                 Value="True">
							<Setter TargetName="ExpandPath"
                                    Property="RenderTransform">
								<Setter.Value>
									<RotateTransform Angle="180"
                                                     CenterX="3"
                                                     CenterY="3"/>
								</Setter.Value>
							</Setter>
							<Setter TargetName="ExpandPath"
                                    Property="Fill"
                                    Value="#FF595959"/>
							<Setter TargetName="ExpandPath"
                                    Property="Stroke"
                                    Value="#FF262626"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<DataTemplate x:Key="{x:Static env:EditorStyleKeys.ProgressInfoTemplateKey}">
		<!-- DataType="{x:Type kui:ProgressInfo}" -->
		<Grid MaxHeight="30">
			<ProgressBar
					Maximum="{Binding Maximum}"
					Value="{Binding Progress}"
					MinWidth="200"
					>
				<ProgressBar.Style>
					<Style TargetType="{x:Type ProgressBar}">
						<Style.Triggers>
							<DataTrigger Binding="{Binding Maximum}" Value="0">
								<Setter Property="IsIndeterminate" Value="True"/>
							</DataTrigger>
						</Style.Triggers>
					</Style>
				</ProgressBar.Style>
			</ProgressBar>
			<TextBlock Text="{Binding Text}" VerticalAlignment="Center" />
		</Grid>
	</DataTemplate>

	<Style TargetType="{x:Type h:EditorHostWindow}"
		   BasedOn="{StaticResource {x:Type Window}}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type h:EditorHostWindow}">
					<AdornerDecorator>
						<h:EditorViewWrapper>
							<h:EditorHostView/>
						</h:EditorViewWrapper>
					</AdornerDecorator>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style TargetType="{x:Type h:EditorHostView}" BasedOn="{StaticResource {x:Type UserControl}}">
		<Setter Property="Background" Value="{DynamicResource {x:Static env:EditorStyleKeys.WorkspaceBackgroundBrushKey}}"/>
	</Style>

	<Style TargetType="{x:Type doc:NavigationView}">
		<Setter Property="ContentTemplateSelector" Value="{x:Static env:AttributedViewTemplateSelector.Default}"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type doc:NavigationView}">
					<DockPanel>
						<ToolBarTray DockPanel.Dock="Top" Background="Transparent">
							<ToolBarTray.Resources>
								<Style TargetType="{x:Type Image}">
									<Setter Property="Stretch" Value="Uniform"/>
									<Setter Property="StretchDirection" Value="Both"/>
									<Setter Property="Width" Value="16"/>
									<Setter Property="Height" Value="16"/>
								</Style>
							</ToolBarTray.Resources>
							<ToolBar>
								<Button Command="{TemplateBinding GoBackCommand}">
									<Image Source="{svc:Image {x:Static svc:StandardImageKeys.Back}}"/>
								</Button>
								<Button Command="{TemplateBinding GoForwardCommand}">
									<Image Source="{svc:Image {x:Static svc:StandardImageKeys.Forward}}"/>
								</Button>
								<Button Command="{Binding OpenNewViewCommand}" CommandParameter="{Binding CurrentDetailViewModel.Content}">
									<Image Source="{svc:Image {x:Static svc:StandardImageKeys.NewWindow}}"/>
								</Button>
							</ToolBar>
						</ToolBarTray>

						<ContentPresenter Margin="0 6 0 0"/>
					</DockPanel>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style x:Key="{x:Static env:EditorStyleKeys.TreeNodeStyleKey}" TargetType="{x:Type TreeViewItem}">
		<Setter Property="ItemsSource" Value="{Binding ItemsSource}"/>
		<Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}"/>

		<Style.Triggers>
			<DataTrigger Binding="{Binding HasContextMenu}" Value="True">
				<Setter Property="ContextMenuService.ContextMenu">
					<Setter.Value>
						<ContextMenu ItemsSource="{Binding ContextMenuItems}"/>
					</Setter.Value>
				</Setter>
			</DataTrigger>
		</Style.Triggers>
	</Style>
</ResourceDictionary>